package com.mcx.modules.data.localdata.create;

import com.mcx.modules.data.GameDataTableParser;
import com.mcx.modules.data.base.AbstractDBModel;

/** Item数据管理 */
public class ItemDBModel extends AbstractDBModel<ItemDBModel, ItemEntity>
{
    private static ItemDBModel instance;

    public static ItemDBModel getInstance() {
        if (instance == null) {
            instance = new ItemDBModel();
        }
        return instance;
    }

    /** 文件名称 */
    @Override
    protected String FileName() {
        return "Item.data";
    }

    /** 创建实体 */
    @Override
    protected ItemEntity MakeEntity(GameDataTableParser parse)
    {
        ItemEntity entity = new ItemEntity();
        entity.Id = parse.GetFieldValueToInt("Id");
        entity.Name = parse.GetFieldValueToUTF8String("Name");
        entity.Type = parse.GetFieldValueToInt("Type");
        entity.UsedLevel = parse.GetFieldValueToInt("UsedLevel");
        entity.UsedMethod = parse.GetFieldValueToUTF8String("UsedMethod");
        entity.SellMoney = parse.GetFieldValueToInt("SellMoney");
        entity.Quality = parse.GetFieldValueToInt("Quality");
        entity.Description = parse.GetFieldValueToUTF8String("Description");
        entity.UsedItems = parse.GetFieldValueToUTF8String("UsedItems");
        entity.maxAmount = parse.GetFieldValueToInt("maxAmount");
        entity.packSort = parse.GetFieldValueToInt("packSort");
        return entity;
    }
}
